package org.arnetminer.personalized.service;

import java.util.ArrayList;
import java.util.List;

import org.arnetminer.personalized.dao.UserDAO;
import org.arnetminer.personalized.util.Global;
import org.arnetminer.personalized.vo.Conference;
import org.arnetminer.personalized.vo.FollowType;
import org.arnetminer.personalized.vo.Publication;
import org.arnetminer.personalized.vo.User;

public class RecommendationServiceImpl implements RecommendationService {

	public static final int REC = 2;

	private UserDAO userDAO;

	public UserDAO getUserDAO() {
		return userDAO;
	}

	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}

	private FollowService followService;

	public FollowService getFollowService() {
		return followService;
	}

	public void setFollowService(FollowService followService) {
		this.followService = followService;
	}

	@Override
	public List<User> getRecommendExpert(User user) {
		
		List<User> experts = new ArrayList<User>();
		List<User> users = userDAO.findAll();
		FollowType type = followService.getFollowType(Global.LOCALTYPE);
		int recs = 0;
		for (int i = 0; i < users.size() && recs < REC; i++) {
			if (user.getId() != users.get(i).getId()
					&& !followService
							.isFollow(user, users.get(i).getId(), type)) {
				experts.add(users.get(i));
				recs++;
			}
		}
		return experts;

	}

	@Override
	public List<Conference> getRecommendConference(User user) {
		
		List<Conference> conferences = new ArrayList<Conference>();
		Conference conf = new Conference(Integer.valueOf(1),
				"17th ACM SIGKDD Conference on Knowledge Discovery and Data Mining");
		conferences.add(conf);
		conf = new Conference(Integer.valueOf(2),
				"34th Annual ACM SIGIR Conference on Information Retrieval");
		conferences.add(conf);
		return conferences;
	}

	@Override
	public List<Publication> getRecommendPublication(User user) {
		
		List<Publication> pubs = new ArrayList<Publication>();
		Publication pub = new Publication(Integer.valueOf(1),
				"Mining Advisor-Advisee Relationships from Research Publication Networks.");
		pubs.add(pub);
		pub = new Publication(Integer.valueOf(2),
				"ArnetMiner: Extraction and Mining of Academic Social Networks.");
		pubs.add(pub);
		return pubs;
	}

}
